<%@page import="com.sbl.bajw.util.LogUtil"%>
<%@page import="org.apache.log4j.Logger"%>
<%@page import="com.sbl.bajw.util.ExecptionUtil"%>
<%@page import="java.io.StringWriter"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="java.io.Writer"%>
<%@page import="com.sbl.bajw.common.web.MessageException"%>
<%@page import="com.sbl.bajw.util.JsonUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String json = null;
	
	try{
		Object exceptionObj = request.getAttribute("exception");
		java.util.Map<String,String> map = new java.util.HashMap<String,String>();
		if(exceptionObj instanceof MessageException){
			MessageException msgExc = (MessageException)exceptionObj;
			String errorCode = msgExc.getErrorCode();
			map.put("msg", msgExc.getMessage());
			map.put("success","false");
			map.put("code", errorCode == null || errorCode.equals("")?"3":errorCode);
		}
		else if(exceptionObj instanceof Exception){
			Logger log = LogUtil.getLogger("syslog");
			Exception exc = (Exception)exceptionObj;
			String result = ExecptionUtil.getStackTrace(exc);
	        map.put("msg", result.toString());
			map.put("code","4");
			map.put("success","false");
			log.error("系统错误", exc);
		}
		else{
			map.put("msg", "错误");
			map.put("code","3");
		}
		json = JsonUtil.ConvertObjectToJson(map);		
	}
	catch(Exception e){
		json = "{\"msg\":\"错误\",\"code\":\"3\",\"success\":\"false\"}";
	}
%>
<%=json%>